import 'package:flutter/material.dart';
import 'package:flutter_soundmagus/util/util.dart';
import 'package:flutter_soundmagus/widget/widget.dart';

///组联调按钮
class GroupLinkButton extends StatelessWidget {
  final bool linked;
  final String title1;
  final String title2;
  final void Function()? onPressed;
  final void Function()? onLongPress;
  const GroupLinkButton({
    super.key,
    required this.linked,
    required this.title1,
    required this.title2,
    this.onPressed,
    this.onLongPress,
  });

  @override
  Widget build(BuildContext context) {
    final style = TextStyle(color: linked ? Theme.of(context).primaryColor : Colors.white, fontSize: 10);
    Widget child = Row(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        Text(
          title1,
          style: style,
        ),
        ImgBtn(
          'ch_link',
          selected: linked,
          width: 20.w,
        ),
        Text(
          title2,
          style: style,
        )
      ],
    );
    child = Center(
      child: child,
    );
    return GestureDetector(onTap: onPressed, onLongPress: onLongPress, child: child);
  }
}
